﻿namespace MaBlaApp.Data;

/// <summary>
/// 百度地图定位返回结果
/// </summary>
public class BaiduLocation
{
    public int Accuracy { get; set; }
    public object Altitude { get; set; }
    public object AltitudeAccuracy { get; set; }
    public object Heading { get; set; }
    public double Latitude { get; set; }
    public double Longitude { get; set; }
    public object Speed { get; set; }
    public object Timestamp { get; set; }
    public Point? Point { get; set; }
    public Address? Address { get; set; }
    public int Status { get; set; } = 0;
    public string Error { get; set; } = string.Empty;

    public override string ToString()
    {
        string msg = (Status != 0) ? $"错误码{Status}" : $"{Address}";

        return msg;
    }
}

public class Point
{
    public double Lng { get; set; }
    public double Lat { get; set; }
}

public class Address
{
    public string Country { get; set; } = string.Empty;
    public string City { get; set; } = string.Empty;
    public int City_code { get; set; }
    public string District { get; set; } = string.Empty;
    public string Province { get; set; } = string.Empty;
    public string Street { get; set; } = string.Empty;
    public string Street_number { get; set; } = string.Empty;

    public override string ToString()
    {
        return $"{Province}{City}{District}{Street}{Street_number}";
    }
}

/*
 选择性粘贴，将json粘贴为类
{
    "accuracy": 1999,
    "altitude": null,
    "altitudeAccuracy": null,
    "heading": null,
    "latitude": 22.527458177915,
    "longitude": 113.92798387312,
    "speed": null,
    "timestamp": null,
    "point": {
        "lng": 113.92798387312,
        "lat": 22.527458177915
    },
    "address": {
        "country": "",
        "city": "深圳市",
        "city_code": 0,
        "district": "南山区",
        "province": "广东省",
        "street": "海德二道",
        "street_number": "479"
    }
}
 */